#include <vector>
using namespace std;

class Solution {
public:
    int missingNumber(vector<int>& nums) {
        //利用异或运算
        int n = nums.size()+1;
        int ret = 0;
        while(n--)  ret ^= n;
        for(auto& x : nums ) ret ^= x;
        return ret;
    }
};
//高斯求和
class Solution {
public:
    int missingNumber(vector<int>& nums) {
        int n = nums.size();
        int ret = n*(n+1)/2;
        for(auto& x: nums)  ret-=x;
        return ret;
    }
};